package com.qf.efserver.login.controller;

import com.qf.common.core.annotation.NoLoginCheck;
import com.qf.common.core.common.R;
import com.qf.efserver.login.param.CodeLoginParam;
import com.qf.efserver.login.param.PwdLoginParam;
import com.qf.efserver.login.param.StatureParam;
import com.qf.efserver.login.service.LoginService;
import com.qf.efserver.login.vo.LoginVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Author hehecheng
 * Date 2024/11/8
 * 祝我们都能遇见真诚的人
 * 见字如面
 */
@Api(tags = "登录api")
@RestController
@RequestMapping("/user")
public class LoginController {

    @Autowired
    private LoginService loginService;


    /**
     * 验证码登录
     *
     * @param codeLoginParam
     * @return
     */
    @ApiOperation(value = "用户手机验证码登录",
            notes = "根据用户手机号进行登录，如果没有该用户，创建新用户,新用户密码默认为手机号")
    @NoLoginCheck
    @PostMapping("/codeLogin")
    public R<LoginVO> codeLogin(@RequestBody CodeLoginParam codeLoginParam) {
        LoginVO login = loginService.codeLogin(codeLoginParam);
        return R.ok(login);
    }

    /**
     * 密码登录
     *
     * @param pwdLoginParam
     * @return
     */
    @ApiOperation(value = "用户手机号密码登录")
    @NoLoginCheck
    @PostMapping("/pwdLogin")
    public R<LoginVO> pwdLogin(@RequestBody PwdLoginParam pwdLoginParam) {
        LoginVO loginVO = loginService.pwdLogin(pwdLoginParam);
        return R.ok(loginVO);
    }


}
